﻿#pragma once

#include "CoreMinimal.h"
#include "CustomGameinstance.generated.h"

struct FSlateBrush;
UCLASS()
class SLATEDEMO_API UCustomGameinstance:public UObject
{
	GENERATED_BODY()
public:
	//以下4个函数是获取本地图片,转为UTexture2D
	bool GetImageToBrush(const FString& _TexPath, FSlateBrush& Brush);//将JPG图片转成BRUSH
	TArray<FColor> uint8ToFColor(const TArray<uint8> origin);
	UTexture2D* TextureFromImage(int32 SrcWidth, int32 SrcHeight, TArray<FColor>& SrcData, bool UseAlpha);//将图片转为UTexture2D格式
	UTexture2D* GetLocalTexture(const FString& _TexPath);//通过路径获取图片
	bool LoadImageToTexture2D(const FString& ImagePath, UTexture2D*& InTexture, float& Width, float& Height);


	//以下的操作是获取3D模型中的资源图片,转为UTexture2D
	bool LoadThumbnailsFromPackage(const FString& InPackageFileName, const TSet< FName >& InObjectFullNames, FThumbnailMap& InOutThumbnails);//给予指定资源路径获取其中的资源缩略图
	bool GetAssetPNGToUTexture2D(FString FilePath, FSlateBrush& Brush);//将资源中的缩略图转华为UTexture2D
	//将UTexture2D保存到fileDestination
	bool SaveUTexture2DToPNG(UTexture2D* Img, const FString& fileDestination);
	//将资产中的图片进行保存
	bool SaveAssetToPNG(FString AssetPath,FString SavePath);
};
